﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Scoot.Services
{
	public class ServiceResult
	{
		private IDictionary<string, string> validationErrors;

		internal ServiceResult() : this(null) { }

		internal ServiceResult(IDictionary<string, string> validationErrors)
		{
			if (validationErrors == null)
			{
				this.validationErrors = new Dictionary<string, string>();
			}
			else
			{
				this.validationErrors = validationErrors;
			}
		}

		public bool WasSuccessful { get { return !validationErrors.Any(); } }

		public IDictionary<string, string> ValidationErrors { get { return validationErrors; } }

		public void AddValidationError(string field, string error)
		{
			validationErrors.Add(field, error);
		}

		internal static ServiceResult Successful()
		{
			return new ServiceResult();
		}
	}
}
